using System;

namespace Toenda.Rails {
	namespace Data {
		/// <summary>
		/// Class DBInformation
		/// </summary>
		class DBInfo {
			/// <summary>
			/// Enum DatabaseLocation
			/// </summary>
			enum DatabaseLocation {
				HomeServer = 0,
				OnlineServer = 1
			}

			public static DBInfo Current = new DBInfo();

			// Change this, to have the correct db connection informations.
			private DatabaseLocation m_iOnline = DatabaseLocation.OnlineServer;

			private string m_strServer;
			private string m_strDatabase;
			private string m_strDatabaseUser;
			private string m_strPassword;
			private string m_strUsername;
			private string m_strDefaultIDName;
			private bool m_bTrustCn = false;
			
			/// <summary>
			/// Default Constructor
			/// </summary>
			private DBInfo() {
				switch(m_iOnline) {
					case DatabaseLocation.OnlineServer:
						// ONLINE
						m_strServer = "123.123.123.132\\MSSQL"; // VPS15354\\SQLEXPRESS";//
						m_strDatabase = "zappr";
						m_strDatabaseUser = "dbo";
						m_strPassword = "";
						m_strUsername = "sa";
						m_strDefaultIDName = "pkid";
						m_bTrustCn = false;
						//m_strServer = "123.123.123.132\\MSSQL";
						//m_strDatabase = "zappr";
						//m_strDatabaseUser = "dbo";
						//m_strPassword = "";
						//m_strUsername = "sa";
						//m_strDefaultIDName = "pkid";
						//m_bTrustCn = false;
						break;

					case DatabaseLocation.HomeServer:
						// HOME
						m_strServer = "VANDANGO-MOBILE\\MSSQL2005";
						m_strDatabase = "zappr";
						m_strDatabaseUser = "dbo";
						m_strPassword = "banane";
						m_strUsername = "sa";
						m_strDefaultIDName = "pkid";
						m_bTrustCn = false;
						break;
				}
			}

			/// <summary>
			/// Get server
			/// </summary>
			public string Server {
				get { return m_strServer; }
			}

			/// <summary>
			/// Get Trusted Connection
			/// </summary>
			public string TrustCn {
				get {
					if(m_bTrustCn) return "Trusted_Connection=" + m_bTrustCn + "; ";
					else return "";
				}
			}

			/// <summary>
			/// Get Database
			/// </summary>
			public string Database {
				get { return m_strDatabase; }
			}

			/// <summary>
			/// Get Database User
			/// </summary>
			public string DatabaseUser {
				get { return m_strDatabaseUser; }
			}

			/// <summary>
			/// Get Password
			/// </summary>
			public string Password {
				get { return m_strPassword; }
			}

			/// <summary>
			/// Get Username
			/// </summary>
			public string Username {
				get { return m_strUsername; }
			}

			/// <summary>
			/// Get default table primary key id
			/// </summary>
			public string IDName {
				get { return m_strDefaultIDName; }
			}

			/// <summary>
			/// Get a new GUID
			/// </summary>
			public string NewGUID {
				get { return Guid.NewGuid().ToString(); }
			}
		}
	}
}
